<template>
	<detailbox :title="type == 1 ? '重新编辑' : '新增'" @leftclick="close">
		<div slot="right" class="flex_item flex_between">
			<div v-if="type == 1" class="error error_f f12 ml10 flex_start">
				<i class="f14 el-icon-error"></i>
				审核未通过:
				<span class="ml30">
					{{ checkItem.type == 1 ? '审核人:' : checkItem.type == 3 ? '记录责任人:' : checkItem.type == 4 ? '批准人:' : '' }} {{ checkItem.createUserName }}
				</span>
				<span class="ml30">未通过原因: {{ checkItem.content }}</span>
			</div>
			<div v-else></div>
			<div class="flex_end">
				<el-button type="success" size="small" @click="addFile" v-if="type != 1">添加新增</el-button>
				<el-button v-if="type == 1" type="primary" size="small" plain @click="openDialg('showhistory')">审批历史详情</el-button>
				<el-button type="primary" size="small" @click="submit">提交</el-button>
			</div>
		</div>
		<el-row>
			<el-col :span="18">
				<div style="margin-top:10px;" v-for="(form, index) in formList" :key="index" :id="'item' + index">
					<basic-container>
						<div class="main_title success_f flex_between">
							<b>
								管理信息
								<span v-if="formList.length > 1">({{ index + 1 }})</span>
							</b>
							<el-button type="danger" size="small" plain v-if="index != 0" @click="delFile(index)">删除</el-button>
						</div>
						<el-divider></el-divider>
						<div class="mb20">
							<span class="index_num success_bg">1</span>
							<b class="f14">基础信息</b>
						</div>
						<div>
							<el-form size="small" inline model="form">
								<el-form-item label="采购品检验管理编号:" required>
									<el-input v-model="form.number" placeholder="数据带入" class="w160 ml10" readonly v-if="form.numberType == 0"></el-input>
									<el-input class="ml10 w160" placeholder="请输入" v-model="form.number" v-if="form.numberType == 1"></el-input>
									<el-popover placement="top-start" title="编号规则:" width="220" trigger="hover">
										<div>
											<p>CGJY--------采购检验</p>
											<p>xxxx---------年月日(编辑日期，8位)</p>
											<p>xx---------流水号,从01开始</p>
										</div>
										<i slot="reference" class="el-icon-question f18 gray_f ml10"></i>
									</el-popover>
								</el-form-item>

								<el-row>
									<el-col :span="12">
										<el-form-item label="采购品类别:" required>
											<el-radio-group v-model="form.purchaseType" @change="getdevelopmentplanList($event, form)">
												<el-radio :label="0">原材料</el-radio>
												<el-radio :label="1">设备</el-radio>
												<el-radio :label="2">外包服务</el-radio>
												<el-radio :label="3">计算机应用软件</el-radio>
											</el-radio-group>
										</el-form-item>
									</el-col>
									<el-col :span="12" v-if="form.purchaseType == 0">
										<el-form-item label="原材料批号:" required>
											<el-select
												v-model="form.batchNumber"
												no-data-text=""
												class="w160"
												placeholder="请输入/搜索"
												filterable
												default-first-option
												@change="getCaiGouData(form,$event)"
											>
												<el-option v-for="item in form.developmentplanList" :key="item.id" :label="item.materialNumber" :value="item.id"></el-option>
											</el-select>
										</el-form-item>
									</el-col>

									<el-col :span="12" v-if="form.purchaseType == 1">
										<el-form-item label="设备名称:" required>
											<el-select
												v-model="form.deviceName"
												no-data-text=""
												class="w160"
												placeholder="请输入/搜索"
												filterable
												default-first-option
												@change="getItemData($event, form)"
											>
												<el-option v-for="item in form.mainDataList" :key="item.id" :label="item.deviceName" :value="item.id"></el-option>
											</el-select>
										</el-form-item>
									</el-col>
									<el-col :span="12" v-if="form.purchaseType == 2">
										<el-form-item label=" 外包服务名称:" required>
											<el-select
												v-model="form.outsourcingName"
												no-data-text=""
												class="w160"
												placeholder="请输入/搜索"
												filterable
												default-first-option
												@change="getItemData($event, form)"
											>
												<el-option v-for="item in form.mainDataList" :key="item.id" :label="item.outsourcingName" :value="item.id"></el-option>
											</el-select>
										</el-form-item>
									</el-col>

									<el-col :span="12" v-if="form.purchaseType == 3">
										<el-form-item label="计算机应用软件名称:" required>
											<el-select
												v-model="form.softwareName"
												no-data-text=""
												class="w160"
												placeholder="请输入/搜索"
												filterable
												default-first-option
												@change="getItemData($event, form)"
											>
												<el-option v-for="item in form.mainDataList" :key="item.id" :label="item.softwareName" :value="item.id"></el-option>
											</el-select>
										</el-form-item>
									</el-col>
								</el-row>
								<template v-if="form.purchaseType == 0">
									<el-row>
										<el-col :span="12">
											<el-form-item label="检验日期:" required>
												<el-date-picker
													v-model="form.examinDate"
													value-format="yyyy-MM-dd"
													type="date"
													placeholder="选择日期"
													class="w160"
												></el-date-picker>
											</el-form-item>
										</el-col>
										<el-col :span="12">
											<el-form-item label="检验部门:" required>
												<el-cascader
													class="w160"
													placeholder="请选择"
													ref="newdept"
													:options="deptOption"
													v-model="form.manageDeptId"
													:show-all-levels="false"
													:props="{
														value: 'id',
														label: 'deptName',
														emitPath: false,
														checkStrictly: true
													}"
													filterable
													@change="getMemberOption($event, index)"
												></el-cascader>
											</el-form-item>
										</el-col>
										<el-col :span="12">
											<el-form-item label="检验员:" required>
												<el-select placeholder="请选择" v-model="form.manageUserId" class="w160" filterable @change="selectChange($event, form)">
													<el-option v-for="item in form.memberOption" :key="item.id" :value="item.id" :label="item.name"></el-option>
												</el-select>
											</el-form-item>
										</el-col>
										<el-col :span="12">
											<el-form-item label="编制部门:" required>
												<el-input v-model="userInfo.deptName" placeholder="数据带入" readonly class="w160"></el-input>
											</el-form-item>
										</el-col>
									</el-row>
									<div class="f14 mb20">
										原材料
										<el-button size="mini" class="el-icon-circle-plus-outline ml10" type="primary" plain @click="addItem(form, 0)">增加</el-button>
									</div>
									<div class="reviewCon mb20" v-for="(item, i) in form.materialList" :key="i">
										<div class="reviewList">
											<el-row class="flex_warp">
												<el-col :span="8">
													<el-form-item label="原材料名称:" required>
														<el-select
															placeholder="请输入/搜索"
															class="w160"
															filterable
															v-model="item.materialName"
															@change="materialChange($event, form, item)"
														>
															<el-option v-for="(v, i) in form.mainDataList" :key="i" :label="v.cailiaoName" :value="v.id"></el-option>
														</el-select>
													</el-form-item>
												</el-col>
												<el-col :span="8">
													<el-form-item label="规格型号:" required>
														<el-select
															placeholder="请输入/搜索"
															class="w160"
															filterable
															v-model="item.materialSku"
															@change="materialChange($event, form, item)"
														>
															<el-option v-for="(v, i) in form.mainDataList" :key="i" :label="v.cailiaoSku" :value="v.id"></el-option>
														</el-select>
													</el-form-item>
												</el-col>
												<el-col :span="8">
													<el-form-item label="原材料编号:" required>
														<el-input readonly placeholder="数据带入" class="w160" v-model="item.materialNumber"></el-input>
													</el-form-item>
												</el-col>
											</el-row>
											<el-row>
												<el-col :span="16">
													<el-form-item label="检验方式:" required>
														<el-select placeholder="请选择" v-model="item.examineType" class="w160">
															<el-option :value="0" label="全部检验"></el-option>
															<el-option :value="1" label="计数抽样检验"></el-option>
														</el-select>
														<el-button class="ml10" type="primary" v-if="item.examineType == 1" @click="onShowExamine(item)">样本检验</el-button>
													</el-form-item>
												</el-col>
												<el-col :span="8" v-if="item.isHege">
													<el-form-item label="批量接收/批量拒收：">
														<el-input placeholder="数据带出" readonly class="w100" :value="form.isHege === 0 ? '合格' : '不合格'"></el-input>
													</el-form-item>
												</el-col>
											</el-row>
											<template v-if="item.examineType == 0">
												<div class="f14 mb20"><b>全部检验</b></div>
												<div class="reviewCon mb20">
													<el-row class="reviewList">
														<el-col :span="8">
															<el-form-item label="合格品数量:" required>
																<el-input placeholder="请输入" class="w160" v-model="item.qualifiedQty"></el-input>
															</el-form-item>
														</el-col>
														<el-col :span="8">
															<el-form-item label="不合格品数量:" required>
																<el-input placeholder="请输入" class="w160" v-model="item.failedQty"></el-input>
															</el-form-item>
														</el-col>
														<el-col :span="8">
															<el-form-item label="单位:" required>
																<el-input placeholder="数据带入" class="w160" v-model="item.unit" readonly></el-input>
															</el-form-item>
														</el-col>
													</el-row>
												</div>
											</template>
											<i class="error_f el-icon-delete pointer f20 delete" @click="delItem(form, i, 0)" v-if="i > 0"></i>
											<div>
												<el-form-item label="是否使用检验设备:">
													<el-select placeholder="请选择" class="w100" v-model="item.isUser" @change="getdeviceDataList($event, item)">
														<el-option :value="0" label="否"></el-option>
														<el-option :value="1" label="是"></el-option>
													</el-select>
												</el-form-item>
												<el-button
													size="small"
													class="el-icon-circle-plus-outline ml10"
													type="primary"
													plain
													@click="addItem(item, 1)"
													v-if="item.isUser == 1"
												>
													增加
												</el-button>
											</div>
											<div class="reviewCon mb20" v-for="(v, i) in item.deviceList" :key="i">
												<el-row class="reviewList">
													<el-col :span="8">
														<el-form-item label="设备编号:" required>
															<el-select
																v-model="v.deviceNumber"
																no-data-text="未录入设备管理"
																class="w160"
																default-first-option
																filterable
																placeholder="请输入/搜索"
																@change="getdevice($event, v)"
															>
																<el-option v-for="m in deviceList" :key="m.id" :label="m.deviceNumber" :value="m.id"></el-option>
															</el-select>
														</el-form-item>
													</el-col>
													<el-col :span="8">
														<el-form-item label="设备名称:" required>
															<el-select
																v-model="v.deviceName"
																no-data-text="未录入设备管理"
																class="w160"
																default-first-option
																filterable
																placeholder="请输入/搜索"
																@change="getdevice($event, v)"
															>
																<el-option v-for="m in deviceList" :key="m.id" :label="m.name" :value="m.id"></el-option>
															</el-select>
														</el-form-item>
													</el-col>
													<el-col :span="8">
														<el-form-item label="设备型号:" required>
															<el-select v-model="v.deviceModel" no-data-text="未录入设备管理" class="w160" filterable placeholder="请输入/搜索">
																<el-option v-for="m in deviceList" :key="m.id" :label="m.model" :value="m.model"></el-option>
															</el-select>
														</el-form-item>
													</el-col>

													<i class="error_f el-icon-delete pointer f20 delete" @click="delItem(form, i, 1)"></i>
												</el-row>
											</div>
										</div>
									</div>
								</template>
								<template v-else>
									<el-row>
										<el-col :span="12" v-if="form.purchaseType == 1">
											<el-form-item label="设备型号:" required>
												<el-select v-model="form.deviceModel" class="w160" default-first-option filterable placeholder="请输入/搜索" @change="getItemData($event, form)">
													<el-option v-for="m in form.mainDataList" :key="m.id" :label="m.deviceModel" :value="m.id"></el-option>
												</el-select>
											</el-form-item>
										</el-col>
										<el-col :span="12" v-if="form.purchaseType == 1">
											<el-form-item label="设备编号:" required>
												<el-input placeholder="数据带入" class="w160" readonly v-model="form.deviceNumber"></el-input>
											</el-form-item>
										</el-col>
										<el-col :span="12" v-if="form.purchaseType == 3">
											<el-form-item class="m0" label="计算机应用软件版本:" required>
												<el-select v-model="form.softwareVersion" class="w160" placeholder="请输入/搜索" default-first-option  filterable @change="getItemData($event, form)">
													<el-option v-for="m in form.mainDataList" :key="m.id" :label="m.softwareVersion" :value="m.id"></el-option>
												</el-select>
											</el-form-item>
										</el-col>
										<el-col :span="12">
											<el-form-item label="检验日期:" required>
												<el-date-picker
													v-model="form.examinDate"
													value-format="yyyy-MM-dd"
													type="date"
													placeholder="选择日期"
													class="w160"
												></el-date-picker>
											</el-form-item>
										</el-col>
										<el-col :span="12">
											<el-form-item label="检验部门:" required>
												<el-cascader
													class="w160"
													placeholder="请选择"
													ref="newdept"
													:options="deptOption"
													v-model="form.manageDeptId"
													:show-all-levels="false"
													:props="{
														value: 'id',
														label: 'deptName',
														emitPath: false,
														checkStrictly: true
													}"
													filterable
													@change="getMemberOption($event, index)"
												></el-cascader>
											</el-form-item>
										</el-col>
										<el-col :span="12">
											<el-form-item label="检验员:" required>
												<el-select placeholder="请选择" v-model="form.manageUserId" class="w160" default-first-option filterable @change="selectChange($event, form)">
													<el-option v-for="item in form.memberOption" :key="item.id" :value="item.id" :label="item.name"></el-option>
												</el-select>
											</el-form-item>
										</el-col>
										<el-col :span="12">
											<el-form-item label="编制部门:" required>
												<el-input v-model="userInfo.deptName" placeholder="数据带入" readonly class="w160"></el-input>
											</el-form-item>
										</el-col>
									</el-row>
								</template>
								<template v-if="form.purchaseType != 0">
									<el-row>
										<el-col :span="16">
											<el-form-item label="检验方式:" required>
												<el-select placeholder="请选择" v-model="form.examineType" class="w160">
													<el-option :value="0" label="全部检验"></el-option>
													<el-option :value="1" label="计数抽样检验"></el-option>
												</el-select>
												<el-button class="ml10" type="primary" v-if="form.examineType == 1" @click="onShowExamine(form)">样本检验</el-button>
											</el-form-item>
										</el-col>
										<el-col :span="8" v-if="form.isHege">
											<el-form-item label="批量接收/批量拒收：">
												<el-input placeholder="数据带出" readonly class="w100" :value="form.isHege === 0 ? '合格' : '不合格'"></el-input>
											</el-form-item>
										</el-col>
									</el-row>
									<template v-if="form.examineType == 0">
										<div class="f14 mb20"><b>全部检验</b></div>
										<div class="reviewCon mb20">
											<el-row class="reviewList">
												<el-col :span="8">
													<el-form-item label="合格品数量:" required>
														<el-input placeholder="请输入" class="w160" v-model="form.qualifiedQty"></el-input>
													</el-form-item>
												</el-col>
												<el-col :span="8">
													<el-form-item label="不合格品数量:" required>
														<el-input placeholder="请输入" class="w160" v-model="form.failedQty"></el-input>
													</el-form-item>
												</el-col>
												<el-col :span="8">
													<el-form-item label="单位:" required>
														<el-input placeholder="数据带入" class="w160" v-model="form.unit" readonly></el-input>
													</el-form-item>
												</el-col>
											</el-row>
										</div>
									</template>
									<div>
										<el-form-item label="是否使用检验设备:">
											<el-select placeholder="请选择" class="w100" v-model="form.isUser" @change="getdeviceDataList($event, form)">
												<el-option :value="0" label="否"></el-option>
												<el-option :value="1" label="是"></el-option>
											</el-select>
										</el-form-item>
										<el-button size="small" class="el-icon-circle-plus-outline ml10" type="primary" plain @click="addItem(form, 1)" v-if="form.isUser == 1">
											增加
										</el-button>
									</div>
									<div class="reviewCon mb20" v-for="(item, i) in form.deviceList" :key="i">
										<el-row class="reviewList">
											<el-col :span="8">
												<el-form-item label="设备编号:" required>
													<el-select
														v-model="item.deviceNumber"
														no-data-text="未录入设备管理"
														class="w160"
														filterable
														default-first-option
														placeholder="请搜索/选择"
														@change="getdevice($event, item)"
													>
														<el-option v-for="m in deviceList" :key="m.id" :label="m.deviceNumber" :value="m.id"></el-option>
													</el-select>
												</el-form-item>
											</el-col>
											<el-col :span="8">
												<el-form-item label="设备名称:" required>
													<el-select
														v-model="item.deviceName"
														no-data-text="未录入设备管理"
														class="w160"
														filterable
														default-first-option
														placeholder="请搜索/选择"
														@change="getdevice($event, item)"
													>
														<el-option v-for="m in deviceList" :key="m.id" :label="m.name" :value="m.id"></el-option>
													</el-select>
												</el-form-item>
											</el-col>
											<el-col :span="8">
												<el-form-item label="设备型号:" required>
													<el-select
														v-model="item.deviceModel"
														no-data-text="未录入设备管理"
														class="w160"
														default-first-option
														filterable
														placeholder="请输入/搜索"
													>
														<el-option v-for="m in deviceList" :key="m.id" :label="m.model" :value="m.model"></el-option>
													</el-select>
												</el-form-item>
											</el-col>
											<i class="error_f el-icon-delete pointer f20 delete" @click="delItem(form, i, 1)"></i>
										</el-row>
									</div>
								</template>
							</el-form>
						</div>
						<div style="margin-bottom: 10px;"><creat-file :form="form"></creat-file></div>
					</basic-container>
				</div>
			</el-col>
			<el-col :span="6" style="margin-top:10px;"><creat-flow ref="creatFlow" :formList="formList"></creat-flow></el-col>
		</el-row>
		<steps ref="steps" @close="success()" :nowdate="nowdate"></steps>
		<confirm
			ref="confirm"
			@close="save()"
			type="1"
			:guifanFilesProcessRecordList="guifanFilesProcessRecordList"
			:systemGuifanFilesProcessList="systemGuifanFilesProcessList"
		></confirm>
		<showhistory ref="showhistory" type="1" :guifanFilesProcessRecordList="guifanFilesProcessRecordList"></showhistory>
		<examine-creat ref="examineCreat" :parentItem="item" @onConfirm="examineCreatConfirm"></examine-creat>
	</detailbox>
</template>

<script>
// const moment = require('moment');
import examineCreat from '@/components/examine-creat';
import confirm from './confirm.vue';
import { savefiles, getguifanDetail, update, getguifanList } from '@/api/myapi/tixiwenjian';
export default {
	props: {
		detailId: '',
		type: {
			type: [Number, String],
			default: 0
		}
	},
	components: {
		confirm,
		examineCreat
	},
	data() {
		return {
			currentItem: {},
			system: 'purchaseexamineprocess',
			deviceList: [],
			formList: [
				{
					isUser: 0,
					numberType: 0,
					developmentplanList: [],
					purchaseType: 0,
					jiluFileList: [],
					guifanFileList: [],
					materialList: [{}],
					memberOption: []
				}
			],
			guifanFilesProcessRecordList: [],
			systemGuifanFilesProcessList: []
		};
	},
	created() {
		if (this.detailId) {
			this.getDetail();
		} else {
			this.findTypeByProcessType();
		}
		this.getdeptlist();
		this.getdevelopmentplanList();
	},
	methods: {
		onShowExamine(item) {
			this.currentItem = item;
			this.$refs.examineCreat.setForm(item);
		},
		examineCreatConfirm(examine) {
			console.log(examine);
			this.currentItem = examine;
		},
		getDetail() {
			getguifanDetail(
				{
					id: this.detailId
				},
				this.system
			).then(({ data }) => {
				console.log(data);
				if (data.success) {
					if (this.type == 2) {
						delete data.data.id;
						data.data.number = '';
						data.data.numberType = 0;
						this.findTypeByProcessType();
					}
					this.formList = [data.data];
					this.formList.forEach((item, index) => {
						item.deviceList && item.deviceList.length != 0 ? (item.isUser = 1) : (item.isUser = 0);
						this.getuserByDept(item.manageDeptId, item);
					});
					this.guifanFilesProcessRecordList = data.data.processRecordList;
					this.checkItem = this.guifanFilesProcessRecordList.find(item => item.checkStatus == 2);
					this.$nextTick(() => {
						this.$refs.creatFlow.setProcessRecord(this.guifanFilesProcessRecordList);
					});
				}
			});
		},
		selectOutSourcing(id, form) {
			let item = form.mainDataList.find(e => e.id == id);
			form.outsourcingName = item.outsourcingName;
		},
		//  采购管理列表原材料
		getdevelopmentplanList(type = 0, form) {
			if(type==0){
				let parmas={
					current: 1,
					size: 10000,
					processStatus:7,
					purchaseType:0
				}
				getguifanList(parmas,'purchasemanageprocess').then(({ data }) => {
					console.log('采购管理列表');
					console.log(data);
					if (data && data.success) {
						if (form) {
							form.batchNumber = '';
							this.$set(form, 'developmentplanList', data.data.records);
						} else {
							this.formList[0].developmentplanList = data.data.records;
							this.developmentplanList=data.data.records;
						}
					}
				});
			}else{
				this.getCaiGouData(form);
			}
		},
		//   采购管理信息表
		getCaiGouData(form,id){
			let type=form.purchaseType;
			let url=type ==0?'purchasemanagecailiao':type ==1?'purchasemanagedevice':type ==2?'purchasemanageoutsourcing':'purchasemanagesoftware';
			let parmas={
				current: 1,
				size: 10000,
				isTongguo:1
			}
			if(type==0){
				parmas.processId=id;
				let item=form.developmentplanList.find(el=>el.id==id);
				form.batchNumber=item.materialNumber;
			}
			getguifanList(parmas,url).then(({ data }) => {
				console.log('采购管理信息表');
				console.log(data);
				if (data && data.success) {
					this.$set(form, 'mainDataList', data.data.records);
				}
			});
		},
		getdevice(id, form) {
			let item = this.deviceList.find(e => e.id == id);
			form.deviceName = item.name;
			form.deviceModel = item.model;
			form.deviceNumber = item.deviceNumber;
		},
		//  设备管理
		getdeviceDataList(id, form) {
			if (id == 0) form.deviceList = [];
			if (this.deviceList.length == 0) {
				this.getDevice();
			}
		},
		addItem(form, type) {
			if (type == 0) {
				if (!form.materialList) this.$set(form, 'materialList', []);
				form.materialList.push({});
			} else {
				if (!form.deviceList) this.$set(form, 'deviceList', []);
				form.deviceList.push({});
			}
			this.$forceUpdate();
		},
		delItem(form, i, type) {
			if (type == 0) {
				form.materialList.splice(i, 1);
			} else {
				form.deviceList.splice(i, 1);
				if (form.deviceList.length == 0) {
					form.isUser = 0;
				}
			}
		},
		getItemData(id, form) {
			let item = form.mainDataList.find(e => e.id == id);
			form.unit=item.unit;
			 if (form.purchaseType == 1) {
				form.deviceModel = item.deviceModel;
				form.deviceName = item.deviceName;
				form.deviceName = item.deviceName;
			} else if (form.purchaseType == 2) {
				form.outsourcingName = item.outsourcingName;
			} else {
				form.softwareName = item.softwareName;
				form.softwareVersion = item.softwareVersion;
			}
		},
		materialChange(val, form, item) {
			let currentItem = form.mainDataList.find(e => e.id == val);
			item.materialNumber = currentItem.cailiaoNumber;
			item.materialName = currentItem.cailiaoName;
			item.materialSku = currentItem.cailiaoSku;
			item.unit = currentItem.cailiaoUnit;
			console.log(item);
		},
		getMemberOption(val, index) {
			let dept = this.$refs.newdept[index].getCheckedNodes();
			this.formList[index].manageDeptName = dept[0].label;
			this.formList[index].manageDeptId = dept[0].value;
			this.formList[index].manageUserId = '';
			this.formList[index].manageUserName = '';
			this.getuserByDept(val, this.formList[index]);
		},
		close() {
			this.$emit('close');
		},
		submit() {
			let systemGuifanFilesProcessList = [];
			let guifanFilesProcessRecordList = this.$refs.creatFlow.guifanFilesProcessRecordList;
			let isOnlineReview = this.$refs.creatFlow.isOnlineReview;
			for (let i = 0; i <= guifanFilesProcessRecordList.length - 1; i++) {
				let item = guifanFilesProcessRecordList[i];
				item.sort=i;
				if (item.type == 1 && !item.userId) {
					this.$message.error('请选择审核人员');
					return;
				}
				if (item.type == 4 && !item.userId) {
					this.$message.error('请选择批准人员');
					return;
				}
				if (isOnlineReview && item.type == 3 && !item.userId) {
					this.$message.error('请选择记录责任人');
					return;
				}
			}
			for (let i = 0; i < this.formList.length; i++) {
				let item = this.formList[i];
				let arr = [
					{
						value: item.number,
						tips: '请补充采购品检验管理编号'
					},
					{
						value: item.purchaseType == 0 ? item.batchNumber :true,
						tips: '请选择原材料批号'
					},
					{
						value: item.purchaseType == 1 ? item.deviceName : true,
						tips: '请选择设备名称'
					},
					{
						value: item.purchaseType == 2 ? item.outsourcingName : true,
						tips: '请选择外包服务名称'
					},
					{
						value: item.purchaseType == 3 ? item.softwareName : true,
						tips: '请选择计算机应用软件名称'
					},
					{
						value: item.purchaseType == 3 ? item.softwareVersion : true,
						tips: '请选择计算机应用软件版本'
					},
					{
						value: item.examinDate,
						tips: '请选择检验日期'
					},
					{
						value: item.manageDeptId,
						tips: '请选择检验部门'
					},
					{
						value: item.manageUserId,
						tips: '请选择检验人'
					},
					{
						value: item.jiluFilesIds,
						tips: '请添加记录文件'
					},
					{
						value: item.retentionPeriod,
						tips: '请输入记录保留期限'
					},
					{
						value: item.retentionPeriod < 2 ? false : true,
						tips: '记录保留期限应≥2年'
					}
				];
				for (let j = 0; j < arr.length; j++) {
					if (!arr[j].value) {
						this.$message.error(arr[j].tips);
						return;
					}
				}
				item.createDeptName = this.userInfo.deptName;
				item.createUserName = this.userInfo.user_name;
				item.createUserId = this.userInfo.user_id;
				item.createDeptId = this.userInfo.dept_id;
				systemGuifanFilesProcessList.push({
					...item,
					processRecordList: guifanFilesProcessRecordList
				});
			}
			this.systemGuifanFilesProcessList = systemGuifanFilesProcessList;
			this.guifanFilesProcessRecordList = guifanFilesProcessRecordList;
			console.log(this.systemGuifanFilesProcessList);
			console.log(this.guifanFilesProcessRecordList);
			this.openDialg('confirm');
		},
		// 保存
		save() {
			if (this.type == 1) {
				console.log(JSON.stringify(this.systemGuifanFilesProcessList));
				update(this.systemGuifanFilesProcessList, this.system).then(({ data }) => {
					if (data.success) {
						this.$message.success('提交成功');
						this.nowdate = this.dateFormat(new Date());
						this.openDialg('steps');
					}
				});
			} else {
				// console.log(this.systemGuifanFilesProcessList)
				savefiles(this.systemGuifanFilesProcessList, this.system).then(({ data }) => {
					if (data.success) {
						this.$message.success('提交成功');
						this.nowdate = this.dateFormat(new Date());
						this.openDialg('steps');
					}
				});
			}
		},
		success() {
			this.$emit('success');
		},
		addFile() {
			this.formList.push({
				numberType: this.numberType,
				number: this.numberType == 0 ? this.findTypeByProcessType(this.liushuihao) : '',
				isUser: 0,
				purchaseType: 0,
				jiluFileList: [],
				guifanFileList: [],
				skuList: [],
				deviceList: [],
				memberOption: []
			});
			let index = this.formList.length - 1;
			setTimeout(() => {
				let document = window.parent.document.getElementById(`item${index}`);
				document.scrollIntoView({ behavior: 'smooth' });
			}, 100);
		}
	}
};
</script>

<style scoped="scoped" lang="scss">
.reviewList {
	background: #ffffff;
	border: 1px dashed #e4e8ed;
	padding: 20px 20px 0 20px;
	position: relative;
}
.delete {
	position: absolute;
	right: 10px;
	top: 10px;
}
.btnbox {
	border: 1px solid #a3cffd;
	opacity: 1;
	border-radius: 3px 0px 0px 3px;
}

.btnleft {
	padding: 0 10px;
}

.btnright {
	border-left: 1px solid #a3cffd;
	padding: 0 10px;
	line-height: 32px;
}

.border {
	border: 1px solid #dcdfe6;
	border-radius: 4px;
	line-height: 32px;
	padding: 0 10px;
}

.preview {
	padding: 10px;
	background-color: #f0f2f5;
	margin-top: 20px;
	margin-left: 10px;
}

.preview .warn_f {
	background-color: #fbf4e0;
	border: 1px solid #f3dea4;
	line-height: 20px;
	padding: 0 4px;
	margin: 20px 0 10px;
}

.preview .tem {
	width: 377px;
	height: 512px;
}

.preview.bigpreview {
	background-color: #ffffff;
}

.preview.bigpreview .tem {
	width: 510px;
	height: 693px;
}

.error {
	background-color: #fceeec;
	border: 1px solid #f9dcd9;
	padding: 6px 10px;
	border-radius: 2px;
}

div::deep .el-checkbox.is-bordered {
	height: 32px;
	padding: 5px 10px;
}

.fileBox {
	position: relative;
	padding: 20px 10px 1px;
	border: 1px dashed #e4e8ed;

	.del {
		position: absolute;
		right: 10px;
		top: 10px;
	}
}

.worktable {
	td,
	th {
		line-height: 28px;
	}
}

.steps {
	.f16 {
		margin-left: 6px;
	}

	.flex_center {
		margin-bottom: 7px;
	}
}

.btnbox {
	border: 1px solid #a3cffd;
	opacity: 1;
	border-radius: 3px 0px 0px 3px;
}

.btnleft {
	padding: 0 10px;
}

.btnright {
	border-left: 1px solid #a3cffd;
	padding: 0 10px;
	line-height: 32px;
}

.border {
	border: 1px solid #dcdfe6;
	border-radius: 4px;
	line-height: 32px;
	padding: 0 10px;
}

.preview {
	padding: 10px;
	background-color: #f0f2f5;
	margin-top: 20px;
	margin-left: 10px;
}

.preview .warn_f {
	background-color: #fbf4e0;
	border: 1px solid #f3dea4;
	line-height: 20px;
	padding: 0 4px;
	margin: 20px 0 10px;
}

.preview .tem {
	width: 377px;
	height: 512px;
}

.preview.bigpreview {
	background-color: #ffffff;
}

.preview.bigpreview .tem {
	width: 510px;
	height: 693px;
}

.error {
	background-color: #fceeec;
	border: 1px solid #f9dcd9;
	padding: 6px 10px;
	border-radius: 2px;
}

div::deep .el-checkbox.is-bordered {
	height: 32px;
	padding: 5px 10px;
}

.jobfile {
	margin-top: 20px;
	display: flex;
	justify-content: center;
}

.jobLeft {
	width: 34%;
}

.leftTitle {
	height: 48px;
	background: #f5f7fa;
	border: 1px solid #ebf0f5;
	opacity: 1;
	line-height: 48px;
	border-radius: 0px;
	padding: 0 15px;
	font-size: 14px;
	font-family: Microsoft YaHei;
	font-weight: 400;
	color: #303133;
	opacity: 1;
}

.leftList {
	height: 98px;
	background: #ffffff;
	border: 1px solid #ebf0f5;
	opacity: 1;
	line-height: 95px;
	border-radius: 0px;
	display: flex;
	justify-content: flex-start;
	align-items: center;
	padding: 0 15px;
}

.cenList {
	height: 48px;
	background: #ffffff;
	border: 1px solid #ebf0f5;
	opacity: 1;
	line-height: 48px;
	padding: 0 15px;
	display: flex;
	justify-content: flex-start;
	align-items: center;
	border-radius: 0px;
}

.fileBtn {
	margin-left: auto;
	margin-right: 10px;
	font-size: 12px;
	font-family: Microsoft YaHei;
	font-weight: 400;
	line-height: 16px;
	color: #909499;
	opacity: 1;
}

.leftBtn {
	margin-left: auto;
	margin-right: 10px;
}

.leftText {
	font-size: 14px;
	font-family: Microsoft YaHei;
	font-weight: 400;
	line-height: 16px;
	color: #606366;
	opacity: 1;
}

.reviewTitle {
	font-size: 14px;
	font-family: Microsoft YaHei;
	font-weight: bold;
	line-height: 0px;
	color: #606366;
	opacity: 1;
	margin-top: 30px;
}

.addReview {
	width: 74px;
	height: 32px;
	margin: 0 20px;
	background: #e6f1fc;
	border: 1px solid #a3cffd;
	opacity: 1;
	border-radius: 3px;
	font-size: 14px;
	font-family: Microsoft YaHei;
	font-weight: 400;
	line-height: 14px;
	color: #126bc9;
	opacity: 1;
	display: flex;
	justify-content: center;
	align-items: center;
}
</style>
